<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      lang="en">
<head th:include="layout :: htmlhead" th:with="title='PKG管理'">
    <meta charset="UTF-8">
    <!--<base th:href="@{/}">-->
<!--
    <link rel="stylesheet" href="layui/css/layui.css">
-->
</head>
<body>
<!--<div style="margin-top: 17px;margin-left: 1103px;">
    <span>搜索：</span><input type="text" style="height: 27px;width: 220px;" id="sear1" placeholder="请输入班级进行模糊查询"/>
</div>-->
<div>
    <div class="layui-row layui-col-space15">
        <div class="layui-col-xs8">
            <blockquote class="layui-elem-quote quoteBox">
                <span style="font-weight:bold;text-align:center;">最新程序安装包</span>
            </blockquote>
            <input type="hidden" th:value="${file_type}" id="fileType"/>
            <input type="hidden" th:value="${area}" id="area"/>
            <table class="layui-hide" id="dPkgTable" lay-filter="tableFilter"></table>
        </div>
        <div class="layui-col-xs4">

        </div>
    </div>
</div>
<!--<script th:src="@{/js/jquery/jquery-3.3.1.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>-->
<script type="text/html" id="opBar">
    <a class="layui-btn layui-btn-xs" lay-event="download"><i class="layui-icon">&#xe601;</i>下载</a>
<!--    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
</script>
<script type="text/javascript"  th:inline="none">
    layui.use(['table','jquery'], function(){
        var table = layui.table;
        var $ = layui.$;
        depData();
        //监听工具条
        table.on('tool(tableFilter)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('功能待开发', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'download'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
                layer.msg("开始下载文件: "+data.depFileName);
                var durl = 'rpt/download/'+data.id+'/app';
                var curWwwPath=window.document.location.href;
                var pathName=window.document.location.pathname;
                var pos=curWwwPath.indexOf(pathName);
                var localhostPath=curWwwPath.substring(0,pos);
                var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
                window.open(localhostPath + projectName+ '/' + durl);
            }
        });

    });

    function depData(){
        var table = layui.table;
        var fileType=$("#fileType").val();
        var area=$("#area").val();
        console.log(fileType+":"+area);
        var host = 'http://'+window.location.host;
        table.render({
            elem: '#dPkgTable'
            ,url: host+'/appm/rpt/showAppPkgData/'+area
            ,limit:10 //默认为10
            ,cols: [[
                {type:'numbers', width:50, title: '序号', sort: true}
                ,{field:'id', width:80, title: '编号', sort: true} //sort：true页面可进行排序操作
                ,{field:'fileType', width:150, title: '类别'}
                ,{field:'fileName', width:250, title: 'PKG文件名', sort: true}
                ,{field:'version', width:150, title: '版本', sort: true}
                ,{field:'suffix',width:100, title: '文件类型'}
                ,{field:'createTime', width:180, title: '上传日期', sort: true}
                ,{field:'right', width:100, title: '常用操作', toolbar: '#opBar'}
            ]]
            ,page: true
            ,done:function(res, curr, count){
                //数据的回调用，可不写
                $("[data-field='id']").css('display','none');
                $("[data-field='suffix']").css('display','none');
                $("[data-field='createTime']").css('display','none');
            }
        });
    }
    /*$("#sear1").keyup(function(event){
        if(event.keyCode ==13){
            var keyWord=$("#sear1").val();
            addData(keyWord);
        }
    });*/
</script>
</body>
</html>